/*
    This file is part of LWX. 

    LWX is the abbreviation of the Light WiMax simulation program which 
    is a ns2 WiMAX network simulation module. LWX allows each user to 
    apply his/her designed scheduling algorithm or other mechanism used 
    in WiMAX network and generate the corresponding simulation results
    for further analysis or other non-commercial purposes.

    Copyright (C) 2008 Yen-Hung Cheng (pplong), NTUST in Taiwan, R.O.C.
    E-Mail: lwx.ns2@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

bool LWX::is_bs(int node_id)
{
  for(int i=0 ;i <lwx_node_list.size();i++)
  {
    if(lwx_node_list.at(i).node_type == NODE_TYPE_BS && lwx_node_list.at(i).node_id == node_id)
    {
      return true;
    }
  }

  // not bs
  return false;
}

int LWX::find_mac_addr(int node_id)
{
  for(int i=0 ;i <lwx_node_list.size();i++)
  {
    if(lwx_node_list.at(i).node_id == node_id)
    {
      return lwx_node_list.at(i).node_mac_addr;
    }
  }
  
  // can't find this mac
  lwx_err_msg("LWX::find_mac_addr(int node_id)","can't find this node id's mac");
  
}

void LWX::lwx_test_msg(string where, string note)
{
   cout << "test "<< Scheduler::instance().clock() << " " << where << " " << note << endl;
}

void LWX::lwx_err_msg(string where, string note)
{
   cout << endl;
   cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl ;
   cout << endl;
   cout << "  your lwx setting gets trouble at " << Scheduler::instance().clock() ;
   cout << ", \n  please check your programe" << endl;
   cout << endl;
   cout << "  error code in:  " << where << endl;
   cout << "  note:  \n         " << note << endl;
   cout << endl;
   cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl ;
   cout << endl;
   exit(1);
}
